<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qevent.cpp -->
  <title>QContextMenuEvent Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QContextMenuEvent</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QContextMenuEvent Class</h1>
<!-- $$$QContextMenuEvent-brief -->
<p>The QContextMenuEvent class contains parameters that describe a context menu event. <a href="#details">More...</a></p>
<!-- @@@QContextMenuEvent -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QContextMenuEvent&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qinputevent.html">QInputEvent</a></td></tr></table></div><ul>
<li><a href="qcontextmenuevent-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#Reason-enum">Reason</a></b> { Mouse, Keyboard, Other }</td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#QContextMenuEvent-2">QContextMenuEvent</a></b>(QContextMenuEvent::Reason <i>reason</i>, const QPoint &amp;<i>pos</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#QContextMenuEvent-1">QContextMenuEvent</a></b>(QContextMenuEvent::Reason <i>reason</i>, const QPoint &amp;<i>pos</i>, const QPoint &amp;<i>globalPos</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#QContextMenuEvent">QContextMenuEvent</a></b>(QContextMenuEvent::Reason <i>reason</i>, const QPoint &amp;<i>pos</i>, const QPoint &amp;<i>globalPos</i>, Qt::KeyboardModifiers <i>modifiers</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPoint &amp;</td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#globalPos">globalPos</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#globalX">globalX</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#globalY">globalY</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QPoint &amp;</td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#pos">pos</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QContextMenuEvent::Reason </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#reason">reason</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#x">x</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qcontextmenuevent.html#y">y</a></b>() const</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QContextMenuEvent-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>Context menu events are sent to widgets when a user performs an action associated with opening a context menu. The actions required to open context menus vary between platforms; for example, on Windows, pressing the menu button or clicking the right mouse button will cause this event to be sent.</p>
<p>When this event occurs it is customary to show a <a href="../qtwidgets/qmenu.html">QMenu</a> with a context menu, if this is relevant to the context.</p>
<p>Context menu events contain a special accept flag that indicates whether the receiver accepted the event. If the event handler does not accept the event then, if possible, whatever triggered the event will be handled as a regular input event.</p>
</div>
<!-- @@@QContextMenuEvent -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Reason$$$Mouse$$$Keyboard$$$Other -->
<h3 class="fn" id="Reason-enum"><a name="Reason-enum"></a>enum QContextMenuEvent::<span class="name">Reason</span></h3>
<p>This enum describes the reason why the event was sent.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QContextMenuEvent::Mouse</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The mouse caused the event to be sent. Normally this means the right mouse button was clicked, but this is platform dependent.</td></tr>
<tr><td class="topAlign"><code>QContextMenuEvent::Keyboard</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The keyboard caused this event to be sent. On Windows, this means the menu button was pressed.</td></tr>
<tr><td class="topAlign"><code>QContextMenuEvent::Other</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">The event was sent by some other means (i.e&#x2e; not by the mouse or keyboard).</td></tr>
</table></div>
<!-- @@@Reason -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QContextMenuEvent$$$QContextMenuEventQContextMenuEvent::ReasonconstQPoint& -->
<h3 class="fn" id="QContextMenuEvent-2"><a name="QContextMenuEvent-2"></a>QContextMenuEvent::<span class="name">QContextMenuEvent</span>(<span class="type"><a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Reason</a></span> <i>reason</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>pos</i>)</h3>
<p>Constructs a context menu event object with the accept parameter flag set to false.</p>
<p>The <i>reason</i> parameter must be <a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Mouse</a> or <a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Keyboard</a>.</p>
<p>The <i>pos</i> parameter specifies the mouse position relative to the receiving widget.</p>
<p>The <a href="qcontextmenuevent.html#globalPos">globalPos</a>() is initialized to <a href="qcursor.html#pos">QCursor::pos</a>(), which may not be appropriate. Use the other constructor to specify the global position explicitly.</p>
<!-- @@@QContextMenuEvent -->
<!-- $$$QContextMenuEvent$$$QContextMenuEventQContextMenuEvent::ReasonconstQPoint&constQPoint& -->
<h3 class="fn" id="QContextMenuEvent-1"><a name="QContextMenuEvent-1"></a>QContextMenuEvent::<span class="name">QContextMenuEvent</span>(<span class="type"><a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Reason</a></span> <i>reason</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>pos</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>globalPos</i>)</h3>
<p>Constructs a context menu event object with the accept parameter flag set to false.</p>
<p>The <i>reason</i> parameter must be <a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Mouse</a> or <a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Keyboard</a>.</p>
<p>The <i>pos</i> parameter specifies the mouse position relative to the receiving widget. <i>globalPos</i> is the mouse position in absolute coordinates.</p>
<!-- @@@QContextMenuEvent -->
<!-- $$$QContextMenuEvent[overload1]$$$QContextMenuEventQContextMenuEvent::ReasonconstQPoint&constQPoint&Qt::KeyboardModifiers -->
<h3 class="fn" id="QContextMenuEvent"><a name="QContextMenuEvent"></a>QContextMenuEvent::<span class="name">QContextMenuEvent</span>(<span class="type"><a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Reason</a></span> <i>reason</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>pos</i>, const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;<i>globalPos</i>, <span class="type"><a href="../qtcore/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a></span> <i>modifiers</i>)</h3>
<p>Constructs a context menu event object with the accept parameter flag set to false.</p>
<p>The <i>reason</i> parameter must be <a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Mouse</a> or <a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Keyboard</a>.</p>
<p>The <i>pos</i> parameter specifies the mouse position relative to the receiving widget. <i>globalPos</i> is the mouse position in absolute coordinates. The <i>modifiers</i> holds the keyboard modifiers.</p>
<!-- @@@QContextMenuEvent -->
<!-- $$$globalPos[overload1]$$$globalPos -->
<h3 class="fn" id="globalPos"><a name="globalPos"></a>const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;QContextMenuEvent::<span class="name">globalPos</span>() const</h3>
<p>Returns the global position of the mouse pointer at the time of the event.</p>
<p><b>See also </b><a href="qcontextmenuevent.html#x">x</a>(), <a href="qcontextmenuevent.html#y">y</a>(), and <a href="qcontextmenuevent.html#pos">pos</a>().</p>
<!-- @@@globalPos -->
<!-- $$$globalX[overload1]$$$globalX -->
<h3 class="fn" id="globalX"><a name="globalX"></a><span class="type">int</span> QContextMenuEvent::<span class="name">globalX</span>() const</h3>
<p>Returns the global x position of the mouse pointer at the time of the event.</p>
<p><b>See also </b><a href="qcontextmenuevent.html#globalY">globalY</a>() and <a href="qcontextmenuevent.html#globalPos">globalPos</a>().</p>
<!-- @@@globalX -->
<!-- $$$globalY[overload1]$$$globalY -->
<h3 class="fn" id="globalY"><a name="globalY"></a><span class="type">int</span> QContextMenuEvent::<span class="name">globalY</span>() const</h3>
<p>Returns the global y position of the mouse pointer at the time of the event.</p>
<p><b>See also </b><a href="qcontextmenuevent.html#globalX">globalX</a>() and <a href="qcontextmenuevent.html#globalPos">globalPos</a>().</p>
<!-- @@@globalY -->
<!-- $$$pos[overload1]$$$pos -->
<h3 class="fn" id="pos"><a name="pos"></a>const <span class="type"><a href="../qtcore/qpoint.html">QPoint</a></span> &amp;QContextMenuEvent::<span class="name">pos</span>() const</h3>
<p>Returns the position of the mouse pointer relative to the widget that received the event.</p>
<p><b>See also </b><a href="qcontextmenuevent.html#x">x</a>(), <a href="qcontextmenuevent.html#y">y</a>(), and <a href="qcontextmenuevent.html#globalPos">globalPos</a>().</p>
<!-- @@@pos -->
<!-- $$$reason[overload1]$$$reason -->
<h3 class="fn" id="reason"><a name="reason"></a><span class="type"><a href="qcontextmenuevent.html#Reason-enum">QContextMenuEvent::Reason</a></span> QContextMenuEvent::<span class="name">reason</span>() const</h3>
<p>Returns the reason for this context event.</p>
<!-- @@@reason -->
<!-- $$$x[overload1]$$$x -->
<h3 class="fn" id="x"><a name="x"></a><span class="type">int</span> QContextMenuEvent::<span class="name">x</span>() const</h3>
<p>Returns the x position of the mouse pointer, relative to the widget that received the event.</p>
<p><b>See also </b><a href="qcontextmenuevent.html#y">y</a>() and <a href="qcontextmenuevent.html#pos">pos</a>().</p>
<!-- @@@x -->
<!-- $$$y[overload1]$$$y -->
<h3 class="fn" id="y"><a name="y"></a><span class="type">int</span> QContextMenuEvent::<span class="name">y</span>() const</h3>
<p>Returns the y position of the mouse pointer, relative to the widget that received the event.</p>
<p><b>See also </b><a href="qcontextmenuevent.html#x">x</a>() and <a href="qcontextmenuevent.html#pos">pos</a>().</p>
<!-- @@@y -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
